/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.sql.Date;
import java.sql.Timestamp;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;

/**
 *
 * @author Ee Ting
 */
@Entity
public class MPSWeeklyRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long mpsWeeklyId;
    
    private int weekNo;
    private Date startDate;
    private Date endDate;
    private ProdRecordMPS mpsMonthly;
    private ProdRecordMPS mpsWeekly;
    private int workingDaysMonthly;
    private int workingDaysWeekly;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private SystemUser createdBy;
    private Timestamp createdDate;
    
    @OneToOne(cascade={CascadeType.PERSIST})
    private SOPRecord sopr;
    
    public void create(int wkNo,java.util.Date sDate, java.util.Date eDate, ProdRecordMPS mpsM,ProdRecordMPS mpsW, int wDaysM, int wDaysW,SystemUser user)
    {
        this.setWeekNo(wkNo);
        this.setStartDate(new Date(sDate.getTime()));
        this.setEndDate(new Date(eDate.getTime()));
        this.setMpsMonthly(mpsM);
        this.setMpsWeekly(mpsW);
        this.setWorkingDaysMonthly(wDaysM);
        this.setWorkingDaysWeekly(wDaysW);
        this.setCreatedBy(user);
        java.util.Date tmp = new java.util.Date();
        this.setCreatedDate(new Timestamp(tmp.getTime()));
    }

    public SOPRecord getSopr() {
        return sopr;
    }

    public void setSopr(SOPRecord sopr) {
        this.sopr = sopr;
    }

    
    public SystemUser getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(SystemUser createdBy) {
        this.createdBy = createdBy;
    }

    public Timestamp getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Timestamp createdDate) {
        this.createdDate = createdDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public ProdRecordMPS getMpsMonthly() {
        return mpsMonthly;
    }

    public void setMpsMonthly(ProdRecordMPS mpsMonthly) {
        this.mpsMonthly = mpsMonthly;
    }

    public ProdRecordMPS getMpsWeekly() {
        return mpsWeekly;
    }

    public void setMpsWeekly(ProdRecordMPS mpsWeekly) {
        this.mpsWeekly = mpsWeekly;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public int getWeekNo() {
        return weekNo;
    }

    public void setWeekNo(int weekNo) {
        this.weekNo = weekNo;
    }

    public int getWorkingDaysMonthly() {
        return workingDaysMonthly;
    }

    public void setWorkingDaysMonthly(int workingDaysMonthly) {
        this.workingDaysMonthly = workingDaysMonthly;
    }

    public int getWorkingDaysWeekly() {
        return workingDaysWeekly;
    }

    public void setWorkingDaysWeekly(int workingDaysWeekly) {
        this.workingDaysWeekly = workingDaysWeekly;
    }

    public Long getMpsWeeklyId() {
        return mpsWeeklyId;
    }

    public void setMpsWeeklyId(Long id) {
        this.mpsWeeklyId = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (mpsWeeklyId != null ? mpsWeeklyId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MPSWeeklyRecord)) {
            return false;
        }
        MPSWeeklyRecord other = (MPSWeeklyRecord) object;
        if ((this.mpsWeeklyId == null && other.mpsWeeklyId != null) || (this.mpsWeeklyId != null && !this.mpsWeeklyId.equals(other.mpsWeeklyId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.MPSWeeklyRecord[ id=" + mpsWeeklyId + " ]";
    }
    
}
